<template>
  <div class="newsinfo-container">
    <h3 class="title">{{ newsinfo.title }}</h3>
    <p class="subtitle">
      <span>发表时间：{{ newsinfo.addTime }}</span>
      <span>点击：{{ newsinfo.click }}</span>
    </p>
    <hr>
    <div class="content">
      {{ newsinfo.content }}
    </div>
    <hr>
    <div class="content">
      <content-box :id='this.id' :its='this.is'></content-box>
    </div>
  </div>
</template>
<script>
import content from '../subcomponents/content.vue'
export default{
  data(){
   return{
     id:this.$route.params.id,
     is:0,
     newsinfo:{}
   }
  },
  methods:{
    getNewsInfo(){
      this.$http.get('getnewsinfo').then(result=>{
          console.log(result)
          if(result.status === 200){
            console.log(result)
            this.newsinfo = result.body.newsinfo[this.id-1]
          }else{
            Toast("等待服务端数据...")
          }
      })
    }
  },
  created (){
    this.getNewsInfo();
  },
  components:{
    "content-box":content
  }
}
</script>
<style lang='scss'>
.newsinfo-container{
  padding: 0 4px;
  .title{
    font-size: 16px;
    // text-align: center;
    padding: 15px 10px;
  }
  .subtitle{
    font-size: 12px;
    color: #226aff;
    display: flex;
    justify-content: space-between;
  }
}
</style>

